/**
 * Created by Administrator on 2016/8/1.
 */

var uuid = require('node-uuid');
var async = require('async');
var crypto = require('crypto');
var loginDao = require('../dao/loginDao');

//登录信息
exports.login = function (params, callback) {
    loginDao.check(params, function (err, data) {
        if (data.length>0) {
            callback(err, data);
        } else {
            var id = uuid.unparse(uuid.v4(null, new Buffer(32), 0));
            var mobile =params.mobile;
            var password = params.password;
            var createAt = new Date();
            // var shasum = crypto.createHash('sha1');//nodejs 加密
            // shasum.update(password);
            // password = shasum.digest('hex');
            var obj ={
                id:id,
                mobile:mobile,
                password:password,
                createAt:createAt,
                status:1
            }
            loginDao.login(obj, function (err, data2) {
                callback(err, data2);
            })

        }

    })
};
